<?php 

/*====================================================
 Author: RooTM
------------------------------------------------------
 Web-site: http://weboss.net/
=====================================================*/

@session_start();
@error_reporting ( E_ALL ^ E_WARNING ^ E_NOTICE );
@ini_set ( 'display_errors', true );
@ini_set ( 'html_errors', false );
@ini_set ( 'error_reporting', E_ALL ^ E_WARNING ^ E_NOTICE );

define( 'DATALIFEENGINE', true );
define( 'ROOT_DIR', substr( dirname(  __FILE__ ), 0, -26 ) );
define( 'ENGINE_DIR', ROOT_DIR . '/engine' );

include ENGINE_DIR . '/data/config.php';

if( $config['http_home_url'] == "" ) {
	
	$config['http_home_url'] = explode( "engine/iLike/ajax.php", $_SERVER['PHP_SELF'] );
	$config['http_home_url'] = reset( $config['http_home_url'] );
	$config['http_home_url'] = "http://" . $_SERVER['HTTP_HOST'] . $config['http_home_url'];

}

require_once ENGINE_DIR . '/classes/mysql.php';
require_once ENGINE_DIR . '/data/dbconfig.php';
require_once ENGINE_DIR . '/modules/functions.php';

$_COOKIE['dle_skin'] = trim(totranslit( $_COOKIE['dle_skin'], false, false ));

if( $_COOKIE['dle_skin'] ) {
	if( @is_dir( ROOT_DIR . '/templates/' . $_COOKIE['dle_skin'] ) ) {
		$config['skin'] = $_COOKIE['dle_skin'];
	}
}

if( $config["lang_" . $config['skin']] ) {
	if ( file_exists( ROOT_DIR . '/language/' . $config["lang_" . $config['skin']] . '/website.lng' ) ) {	
		include_once ROOT_DIR . '/language/' . $config["lang_" . $config['skin']] . '/website.lng';
	} else die("Language file not found");
} else {
	
	include_once ROOT_DIR . '/language/' . $config['langs'] . '/website.lng';

}

include_once ENGINE_DIR . '/modules/iLike/language.lng';

$config['charset'] = ($lang['charset'] != '') ? $lang['charset'] : $config['charset'];

require_once ENGINE_DIR . '/modules/sitelogin.php';

$news_id = trim($_POST['news_id']);

$comment_id = trim($_POST['comment_id']);

if( !is_numeric($news_id) ) die( "error" );

if($_POST['place'] != 'news')if( !is_numeric($comment_id) ) die( "error" );

if($_POST['place'] == 'news') $file_name = ENGINE_DIR . '/modules/iLike/base/news-'.$news_id.'.data';
if($_POST['place'] == 'comments') $file_name = ENGINE_DIR . '/modules/iLike/base/nid-'.$news_id.'_cid-'.$comment_id.'.data';

$like_data = @file_get_contents( $file_name );

$i = 3;

if(preg_match( "<!-- UserID: ".$member_id['user_id']." -->"  , $like_data ) ){

preg_match( '/<!-- UserID: '.$member_id['user_id'].' -->(.*?)\n\n/is' , $like_data , $me );

$like_data = str_replace ( "<!-- UserID: ".$member_id['user_id']." -->".$me[1]."\n\n" , '' ,  $like_data );

$i = 2;

}

$user = explode( "\n\n" , $like_data );

while($i < count($user)-1){
$iLike .= $user[$i].', ';
$i++;
}

$iLike = substr($iLike,0,strlen(trim($iLike))-1);

@header( "Content-type: text/html; charset=" . $config['charset'] );

echo "<div id='ilikeother' title='{$iLike_lang[10]}:' style='display:none;overflow:auto;'>{$iLike}</div>";

?>

